<?php

	class RegisterView {
	
		private $m_usernameInput = "usernameInput";
		private $m_passwordInput = "passwordInput";
		private $m_confirmpasswordInput = "confirmpasswordInput";
		private $m_registerInput = "registerInput";
		private $m_activeController = "activeController";
		
		// Function used to create the Register form.
		// Returns XHTML string
			public function DoRegisterForm() {
	
			return "
			<form method='get'>
				Username: <input type='text'  maxlength='20' name=$this->m_usernameInput></input><br/>
				Password: <input type='password'  maxlength='20' name=$this->m_passwordInput ></input><br/>
				Confirm Password:: <input type='password'  maxlength='20' name=$this->m_confirmpasswordInput ></input><br/>
				Your Password need to be atleast six characters long, and contain atleast one number, one uppercase letter, and one lowercase letter<br/>
				<input type='submit' name=$this->m_registerInput value='Register'/>
				<input type='hidden' name=$this->m_activeController value='Register'/>
			</form>";
		}
		
		//Returns the username input if it exists
		public function GetUserName(){
			if (isset( $_GET[$this->m_usernameInput])) {
				return $_GET[$this->m_usernameInput];
			}
			return null;
		}
		
		//Returns the password input if it exists
		public function GetPassword(){
			if (isset( $_GET[$this->m_passwordInput])) {
				return $_GET[$this->m_passwordInput];		
				}
			return null;
		}
		
		//Returns true if the user pressed the Register button
		public function PressedRegister(){
			if (isset( $_GET[$this->m_registerInput]) == true) {
				return true;
			}
			return false;
		}
		
		//Validates the info in Get
		public function CheckInfo(){
			if(Validate::ValidatePassword($_GET[$this->m_passwordInput]) == false){
				return "Your password is in an incorrect format";
			}
			else if ($_GET[$this->m_passwordInput] != $_GET[$this->m_confirmpasswordInput] ){
				return "Your passwords doesn't match";
			}
			else if(strlen($_GET[$this->m_usernameInput]) == 0){
				return "No Username Entered";
			}
			return true;
		}
		
		public function AddMessageUserCreated(){
			return "New user created. You should be able to log in with your userinfo immediately";
		}
		
		public function AddMessageError(){
			return "An error occured when your new user was being created, please try again";
		}
		
		public function AddHeader(){
			return "<h2>Register New User: </h2>";
		}
	
	}


